package com.qcby.mycommunity_003.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.qcby.mycommunity_003.entity.InOutRecord;
import com.qcby.mycommunity_003.vo.ChartVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author admin
 * @since 2024-03-25
 */
@Mapper
public interface InOutRecordMapper extends BaseMapper<InOutRecord> {
    @Select("SELECT COUNT(*) `value`, c.community_name `name` FROM person p,community c WHERE c.community_id=p.community_id GROUP BY c.community_id")
    public List<ChartVO> charts();

    @Select({
            "select * from in_out_record where " +
                    "community_id=#{communityId} and " +
                    "person_id=#{personId} and out_time is null"
    })
    InOutRecord getInOutRecord(InOutRecord inOutRecord);
}
